package me.zk.practice1.hw;

import java.util.Scanner;

/**
 * @author zhangkai
 * @date 2023/8/8 16:08
 */
public class HWBJ15 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();

        String[] ss = s.split("#");
        if (ss.length != 4) {
            System.out.println("invalid IP");
        }
        long count = 0;
        for (int i = 0; i < ss.length; i++) {
            int a = Integer.parseInt(ss[i]);
            if (i==0 &&(a < 1||a>128)) {
                System.out.println("invalid IP");
                break;
            }
            if (a<0 || a>255) {
                System.out.println("invalid IP");
                break;
            }
            //位运算
            count+= a <<(8 *(3-i));
        }
        System.out.println(count);
    }
}
